<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Retenci&oacute;n del ISLR</title>
<link href="boton.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
@import url("tablas.css");
.style7 {font-size: 12px}
.style6 {font-size: 9.5px}
-->
</style>
</head>

<body>
<?
	$base= "ucg";

	$conexion = mysql_connect("localhost","root","");

	mysql_select_db($base,$conexion);
	
    $sql2="Select * from compra WHERE cod_ser_com='$ordser' and tipo='2'";
	$resultado2 = mysql_query($sql2, $conexion);
	$servicio = mysql_fetch_row($resultado2);
	
	$sql3="Select * from pago WHERE pago.cod='$comegr'";
	$resultado3 = mysql_query($sql3, $conexion);
	$pago = mysql_fetch_row($resultado3);
	
	if ($ordser==""){?>
<form action="calculoislr.php" method="post" target="_self">
	<? echo "Elija una Orden de Servicio";
	 echo "<input type=hidden name='sesion' value='$sesion'>"; echo "<br>";?>
	 <input type="submit" name="Submit" value="Verificar">
</form> <? }
	
	else { ?>
	
<form name="form1" method="post" action="calculoislr.php">
  <table width="100%"  border="1">
    
    <tr bordercolor="#000000">
      <td width="88%"><p class="style7"><strong>Beneficiario:</strong></p></td>
    </tr>
    <tr bordercolor="#000000">
      <td><span class="style7">
      <span class="style6"><? echo "<input type=hidden name='ben' value='$servicio[4]'>$servicio[4]";?></span>      </span></td>
    </tr>
    <tr bordercolor="#000000">
      <td><span class="style7"><strong>RIF del Beneficiario:</strong></span></td>
    </tr>
    <tr bordercolor="#000000">
      <td><span class="style7"><span class="style6"><? echo "<input type=hidden name='rif' value='$servicio[5]'>$servicio[5]";$rif=$servicio[5];if ($rif{0}=="V") $ret="3"; if ($rif{0}=="J") $ret="5";?></span></span></td>
    </tr>
    <? $valor2=$valor;
	
	if (($rif{0}=="V" and $servicio[86]<$nat) or ($rif{0}=="J" and $servicio[86]<$jur)){ ?>
	<td colspan="5" class="celdatodo"><? echo "MONTO MENOR AL ESTABLECIDO PARA RETENER A ESTE TIPO DE PERSONA"; ?> <span class="style7">
      </span></td>
	  <td colspan="5" class="celdatodo"> <? echo $valor2; ?><span class="style7">
      </span></td>
          <? }
	
	else {?>
    <tr class="celdatodo">
      <td colspan="3" class="celdatodo">Monto Total de la Factura Bs. <span class="style7">
      </span></td>
      <td class="celdatodo"><span class="style7">
      <span class="style6"><? $montot=$servicio[86]; echo "<input type=hidden name='montot' value='$montot'>$montot"; ?></span>      </span></td>
      <td class="celdatodo">&nbsp;</td>
    </tr>
    <tr class="celdatodo">
      <td colspan="3" class="celdatodo">Base Imponible Bs. </td>
      <td class="celdatodo"><span class="style7">
      <span class="style6"> <? if ($servicio[83]=="" or $servicio[83]=='0'){$basimp=$montot; echo "<input type=hidden name='basimp' value='$basimp'>$basimp";} else {$basimp= $montot/($iva/100+1); $basimp=round($basimp,2); echo "<input type=hidden name='basimp' value='$basimp'>$basimp";}?></span>      </span></td>
      <td class="celdatodo">&nbsp;</td>
    </tr>
    <tr class="celdatodo">
      <td colspan="3" class="celdatodo">% de Retenci&oacute;n </td>
      <td class="celdatodo"><span class="style7">
      <span class="style6">
      <? if ($rif{0}=="V" and $basimp<$nat) echo "&nbsp;";  if ($rif{0}=="J" and $basimp<$jur)echo "&nbsp;"; if ($rif{0}=="V" and $basimp>$nat) echo "<input type=hidden name='ret' value='$ret'>$ret%"; if ($rif{0}=="J" and $basimp>$jur) echo "<input type=hidden name='ret' value='$ret'>$ret%";?>
      </span></span></td>
      <td class="celdatodo"><? $retencion= $basimp*($ret/100); $retencion=round($retencion,2);?>&nbsp;</td>
    </tr>
    <tr class="celdatodo">
      <td colspan="3" class="celdatodo">Sustraendo Bs. </td>
      <td class="celdatodo"><span class="style7"><span class="style6"><? if ($rif{0}=='V' and $basimp>$nat) {$sus=$tri*($ret/100)*83.3334; $sus=round($sus,2); echo "<input type=hidden name='sus' value='$sus'>$sus";} else {echo"&nbsp;";}
	  
	   if ($rif{0}=='J' and $basimp>$jur) {$sus=0; echo "<input type=hidden name='sus' value='$sus'>$sus";} else {echo"&nbsp;";}?></span></span></td>
      <td class="celdatodo"><? echo "<input type=hidden name='iva' value='$iva'>";
	   echo "<input type=hidden name='tri' value='$tri'>";
	   echo "<input type=hidden name='nat' value='$nat'>";
	   echo "<input type=hidden name='jur' value='$jur'>";
	   echo "<input type=hidden name='sesion' value='$sesion'>";?></td>
    </tr>
    <tr class="celdatodo">
      <td colspan="3" class="celdatodo">Monto a Retener </td>
      <td class="celdatodo"><span class="style7">
      <span class="style6"> <? if ($sus==""){$monret=$retencion; echo"<input type=hidden name='monret' value='$monret'>$monret";} else {$monret=$sus-retencion; $monret=round($monret,2);echo "<input type=hidden name='monret' value='$monret'>$monret";}?></span>      </span></td>
      <td class="celdatodo">&nbsp;</td>
    </tr>
    <tr class="celdatodo">
      <td colspan="3" class="celdatodo">Total a Pagar Bs. </td>
      <td class="celdatodo"><span class="style7">
	     <span class="style6"><? echo "<input type=hidden name='totpag' value='$monret'>$monret";?></span>      </span></td>
      <td class="celdatodo">&nbsp;</td>
    </tr>
	<? } ?>
    <tr>
     <td><span class="style7"><strong>N&ordm; de Orden de Servicio <? echo $ordser; ?></strong></span></td>
    </tr>
    <tr>
      <td><input type="submit" name="Submit" value="Regresar">
      <? echo "<input type=hidden name='sesion' value='$sesion'>";?> </td>
    </tr>
  </table>
  <? }?>
  
  
</body>
</form>

</html>
